<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Abstract
 *
 * @author Andriy
 */
class Core_Controller_Abstract
{
    protected $_application = null;

    protected $_layout = array();

    protected $_request = null;

    protected $view = null;

    public function setApplication( Application $application )
    {
        $this->_application = $application;
        $this->_request = $this->_application->getRequest();
        $this->_layout = $this->_application->getLayout();
        $this->view = $this->_layout->getView();
    }

    public function getApplication()
    {
        return $this->_application;
    }

    public function setRequest( Core_Request $request )
    {
        $this->_request = $request;
    }

    public function getRequest()
    {
        return $this->_request;
    }

    public function __construct()
    {
        
    }

    protected function _init()
    {
    }
    
    protected function _preDispach()
    {
    }

    protected function _postDispach()
    {
    }


    public function render( $view, $layout = null, $module = null )
    {
        $this->_layout->setCurrentModule( $this->_request->getModule() );
        $this->_layout->setCurrentController( $this->_request->getController() );

        $this->_preDispach();
        $result = $this->_layout->render( $view, $layout, $module );
        $this->_postDispach();

        return $result;
    }

    public function run()
    {
        $this->_init();
    }

}
?>
